<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        input {
            width: 400px;
            height: 24px;
            margin-left: 100px;
        }
        div {
            width: 404px;
            height: 500px;
            margin-left: 100px;
            background: #eeeeee;
        }
    </style>
</head>
<body>
    <input oninput="getAutoCompletedHints(this)">
    <div id="content">

    </div>
</body>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>
<script>
    var content = document.getElementById('content')

    function getAutoCompletedHints(inputDom) {
        // console.log(inputDom.value)
        var prefix = inputDom.value;
        if(prefix.trim()) {
            content.innerHTML = ''

            $.getJSON("http://localhost:8080/movie-suggest?prefix=" + prefix.trim(), {}, 
            function(_data) {
                for(var i = 0; i < _data.length; i++) {
                    var pTag = document.createElement('p')
                    pTag.innerText = _data[i];
                    content.appendChild(pTag)
                }
            })
        }
    }
</script>
</html>